/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        int[] arr={5,6};
        System.out.println(getDis(arr,2));
    }

    public static int getDis (int[] A, int n) {
        // write code here
        int right=0;
        int ret=0;
        int min=Integer.MAX_VALUE;
        for(;right<n;right++){
            min=Math.min(min,A[right]);
            if(A[right]>min){
                ret=Math.max(ret,A[right]-min);
            }

        }
        return ret;
    }

}